www.mxdraw.com
内容索引主面
前一个向上下一个
IMxDrawCurve::SplitCurves 方法

打断曲线

IDL
[helpstring("method SplitCurves")]
HRESULT SplitCurves([in] IMxDrawResbuf* aryParam, [out] IMxDrawResbuf** aryNewId, [out,retval] VARIANT_BOOL* isOk);
参数 
说明 
[in] IMxDrawResbuf* aryParam 
打断位置参数数组,或打断的点数组,是个MxDrawResbuf对象。 
[out] IMxDrawResbuf** aryNewId 
返回打断后生成的新曲线id,是个MxDrawResbuf对象。 

成功返回TRUE

例如: VB测试代码

       Private Sub SplitCurves()
       Set mxUtility = New MxDrawXLib.MxDrawUtility

       Dim ent As MxDrawXLib.MxDrawEntity
       Set ent = mxUtility.GetEntity(getPt, Chr(13) + Chr(10) + "选择打断的曲线")

       If (ent Is Nothing) Then
            MsgBox "没有选择实体.."
            Exit Sub
       End If

        Dim curve As MxDrawXLib.MxDrawCurve
        If TypeOf ent Is MxDrawXLib.MxDrawCurve Then
            Set curve = ent
        Else
            MsgBox "实体类型不对"
            Exit Sub
        End If

        Dim getPt1 As MxDrawXLib.MxDrawPoint

        Set getPt1 = mxUtility.GetPoint(, Chr(13) + Chr(10) + "点取打断的位置:")

        If (getPt1 Is Nothing) Then
            MsgBox "用户取消.."
            Exit Sub
        End If


        Set param = New MxDrawXLib.MxDrawResbuf
        param.AddPoint getPt1, -10



        Dim rb  As MxDrawXLib.MxDrawResbuf
        If curve.SplitCurves(param, rb) Then
            MsgBox "打断成功"
            '把原来的删除掉
            curve.Erase

        End If
        End Sub

例如: C#例程

    private void DoSplitCurves()
    {
        MxDrawUtility mxUtility = new MxDrawUtility();
        object getPt;
        MxDrawEntity ent = mxUtility.GetEntity(out getPt, "选择打断的曲线:");
        if (ent == null)
            return;

        MxDrawCurve curve;
        if (ent is MxDrawCurve)
        {
            curve = (MxDrawCurve)ent;
        }
        else
        {
            MessageBox.Show("实体类型不对");
            return;
        }

        MxDrawPoint getPt1 = (MxDrawPoint)(mxUtility.GetPoint(null, "点取打断位置:"));

        if (getPt1 == null)
        {
            MessageBox.Show("用户取消..");
            return;
        }
        MxDrawResbuf param = new MxDrawResbuf();
        param.AddPoint(getPt1, -10);

        MxDrawResbuf objId;
        if (curve.SplitCurves(param,out objId))
        {
            MxDrawResbuf rbId = (MxDrawResbuf)objId;
            MessageBox.Show("打断成功,生成的曲线个数:" + rbId.Count);
            // 把以前的删除掉。

            ent.Erase();
        }
        else
        {
            MessageBox.Show("打断失败");
        }
    }

例如: C#选择曲线,把曲线从中间1/4 到 3/ 4处断开

           MxDrawUtility mxUtility = new MxDrawUtility();
         object getPt;
         MxDrawEntity ent = mxUtility.GetEntity(out getPt, "选择打断的曲线:");
         if (ent == null)
             return;

         MxDrawCurve curve;
         if (ent is MxDrawCurve)
         {
             curve = (MxDrawCurve)ent;
         }
         else
         {
             MessageBox.Show("实体类型不对");
             return;
         }

         double dLen = 0.0;
         curve.GetDistAtParam(curve.GetEndParam(),out dLen);

         object pt1;
         if (!curve.GetPointAtDist(dLen / 4.0, out pt1))
             return;


         object pt2;
         if (!curve.GetPointAtDist(dLen * 3.0 / 4.0, out pt2))
             return;

         MxDrawPoint breakPt1 = (MxDrawPoint)pt1;
         MxDrawPoint breakPt2 = (MxDrawPoint)pt2;
         if (breakPt1 == null || breakPt2 == null)
             return;

         MxDrawResbuf param = new MxDrawResbuf();
         param.AddPoint(breakPt1, -10);
         param.AddPoint(breakPt2, -10);

         MxDrawResbuf objIds;
         if (curve.SplitCurves(param, out objIds))
         {
             MxDrawResbuf rbId = (MxDrawResbuf)objIds;
             if(rbId.Count == 3)
             {
                 axMxDrawX1.Erase(rbId.AtLong(1));
             }

             // 把以前的删除掉。

             ent.Erase();
         }
Copyright (c) 2010. All rights reserved.
你认为该帮助怎么样? 发送反馈信息!